package cn.maxxieyi.aichatbot.enums;

import cn.maxxieyi.aichatbot.service.AiApiService;
import cn.maxxieyi.aichatbot.service.impl.GmoreAiApiServiceImpl;
import cn.maxxieyi.aichatbot.service.impl.LinkAiApiServiceImpl;
import cn.maxxieyi.aichatbot.service.impl.TulingRobotApiServiceImpl;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

import java.util.Arrays;
import java.util.Objects;

/**
 * AI类型枚举
 *
 */
@Getter
@ToString
@AllArgsConstructor
public enum AiTypeEnum {

    /**
     * link.ai
     */
    LINK_AI("link-ai", "link ai", LinkAiApiServiceImpl.class),
    /**
     * gmore.ai
     */
    GMORE_AI("gmore-ai", "gmore ai", GmoreAiApiServiceImpl.class),

    TULING_ROBOT("tuling-robot", "tuling robot", TulingRobotApiServiceImpl.class),
    ;

    private final String type;
    private final String description;
    private final Class<? extends AiApiService> serviceClass;

    /**
     * 通过type获取class
     *
     * @param type
     * @return
     */
    public static Class<? extends AiApiService> getServiceClassByType(String type) {
        return Arrays.stream(values()).filter(aiType -> Objects.equals(type, aiType.getType()))
                .map(AiTypeEnum::getServiceClass)
                .findFirst().orElse(null);
    }


}
